package org.me.marble;

import android.widget.*;

import android.graphics.Color;

/**
 *
 * @author tungi
 */

public class HighScoreView{

    public void showNewHighScore(){
        GameActivity.game.getWindow().setBackgroundDrawable(new BackgroundImage(
        		GameActivity.game,R.drawable.background_newhighscore,Color.BLACK,0.5,0.5).getCurrent());

        GameActivity.game.setContentView(R.layout.newhighscore);
        
        TextView t=(TextView)GameActivity.game.findViewById(R.newhigh.text);
        
        if(OptionsLibrary.game_type.equals("normal")){
        	OptionsLibrary.bestNormal=(int)OptionsLibrary.points;
        	t.setText(Integer.toString((int)OptionsLibrary.points)+" points");
        }
        else if(OptionsLibrary.game_type.equals("point")){
        	OptionsLibrary.bestPoint=(int)OptionsLibrary.points;
        	t.setText(Integer.toString((int)OptionsLibrary.points)+" points");
        }
        else if(OptionsLibrary.game_type.equals("time")){
        	OptionsLibrary.bestTime=OptionsLibrary.points;
        	t.setText(Float.toString(OptionsLibrary.points)+" seconds");
        }
        
        OptionsLibrary.setSavesToDefault();
        
        //play sound effect
        if(OptionsLibrary.sound)
        	SoundManager.playSound(sounds.Win.ordinal(),0,1.0f);
    }

    public void showEndGame(){
        GameActivity.game.getWindow().setBackgroundDrawable(new BackgroundImage(
        		GameActivity.game,R.drawable.background_gameover,Color.BLACK,0.5,0.5).getCurrent());

        GameActivity.game.setContentView(R.layout.gameover);

        TextView t1=(TextView)GameActivity.game.findViewById(R.gameover.text1);
        TextView t2=(TextView)GameActivity.game.findViewById(R.gameover.text2);
        
        if(OptionsLibrary.game_type.equals("normal")){
        	t1.setText(Integer.toString((int)OptionsLibrary.points)+" points");
        	t2.setText("Best:  "+Integer.toString(OptionsLibrary.bestNormal)+" points");
        }
        else if(OptionsLibrary.game_type.equals("point")){
        	t1.setText(Integer.toString((int)OptionsLibrary.points)+" points");
        	t2.setText("Best:  "+Integer.toString(OptionsLibrary.bestPoint)+" points");
        }
        else if(OptionsLibrary.game_type.equals("time")){
        	t1.setText("0.0 seconds");
        	t2.setText("Best:  "+Float.toString(OptionsLibrary.bestTime)+" seconds");
        }        

        OptionsLibrary.setSavesToDefault();
        
        //play sound effect
        if(OptionsLibrary.sound)
        	SoundManager.playSound(sounds.Fail.ordinal(),0,1.0f);
    }
}
